fix: reorder chat history sidebar after new message in existing chat#2795
Merged
hayescode merged 1 commit intoChainlit:mainfrom Feb 24, 2026
Merged
fix: reorder chat history sidebar after new message in existing chat#2795hayescode merged 1 commit intoChainlit:mainfrom
hayescode merged 1 commit intoChainlit:mainfrom
Conversation
When sending a new message in an existing/resumed chat, the thread's position in the sidebar history list was not updated. This happened because the first_interaction event only fires once per session, so subsequent messages never triggered a thread list refresh. Track message count changes and update the active thread's createdAt timestamp when a new user message is detected, which triggers groupByDate to re-sort and move the thread to the top of the list. Fixes Chainlit#2763
hayescode
approved these changes
Feb 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #2763
When sending a new message in an existing (resumed) chat, the chat history sidebar doesn't reorder to move the active chat to the top. This happens because the
first_interactionsocket event only fires once per session — so when a user resumes a thread and sends a message, no thread list refresh is triggered.Changes
useEffectinThreadHistorythat tracks message count changesuser_messageis detected in the current thread, the thread'screatedAtis updated to the current timegroupByDateto re-sort the thread list, moving the active conversation to the topHow it works
The fix watches
messages.lengthand compares it to the previous count via a ref. When:user_message...the thread's
createdAttimestamp is updated, which causes the existinggroupByDatesorting (in thethreadHistoryStateatom effect) to reposition the thread to the top of the "Today" group.Test plan
Summary by cubic
Fixes the chat history sidebar not moving the active thread to the top after sending a message in a resumed chat. The active conversation now reorders immediately.
Written for commit a20b60d. Summary will update on new commits.